package com.midou.administration.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.midou.administration.bo.AppointmentBo;
import com.midou.administration.bo.AppointmentBob;
import com.midou.administration.bo.ZhuohaoBo;
import com.midou.administration.entity.Desk;
import com.midou.administration.entity.DeskType;
import com.midou.administration.mapper.DeskMapper;
import com.midou.administration.mapper.DeskTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.midou.administration.mapper.AppointmentMapper;
import com.midou.administration.entity.Appointment;

import java.util.List;

@Service
public class AppointmentService{
    @Autowired
    private DeskMapper deskMapper;

    @Autowired
    private AppointmentMapper appointmentMapper;

    @Autowired
    private DeskTypeMapper deskTypeMapper;
    /**
     * 查找商家的桌台
     * @param id
     * @return
     */
    public List<DeskType> ZtAll(Integer id){

        return deskTypeMapper.queryZhuotai(id);
    }
    /**
     * 新增预约订餐信息
     */
    public int queryAdd(Appointment appointment)
    {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("desk_id",appointment.getDeskCode());
        Desk desk=deskMapper.selectOne(queryWrapper);
        int c=deskMapper.queryZhuangtai(desk);
        return appointmentMapper.queryAdd(appointment);
    }
    /**
     * 查找所有桌台信息
     */
    public Page querySelect(AppointmentBob appointmentBob){
        List<AppointmentBo> list=appointmentMapper.querySelect(appointmentBob.getPage(),appointmentBob.getId());
        appointmentBob.getPage().setRecords(list);
        return appointmentBob.getPage();
    }
    public int queryDelete(String phone){
        return appointmentMapper.queryDelete(phone);
    }
    /**
     * 桌台号
     */
    public List<Desk> queryZhuoh(ZhuohaoBo zhuohaoBo){
        return deskMapper.queryZhuoh(zhuohaoBo);
    }
}
